#include <gtest/gtest.h>
#include <ota_hal_test.h>

using namespace android;

using android::sp;

static sp<IOta> mOta;

void OtaHalTest::SetUp() {
    mOta = IOta::getService();
}

void OtaHalTest::TearDown() {}

bool instanceIsNotNull(sp<IOta> instance) {
    return instance != NULL ? true : false;
}

TEST_F(OtaHalTest, getInstance) {
    EXPECT_EQ(true, instanceIsNotNull(mOta));
}

TEST_F(OtaHalTest, init_ota_ipcp) {
    StatusCode ret = mOta->init_ota_ipcp();
    ASSERT_EQ(StatusCode::FAILED, ret);
}

TEST_F(OtaHalTest, requestOTAAssignment) {
    StatusCode ret = mOta->requestOTAAssignment();
    ASSERT_EQ(StatusCode::SUCCESS, ret);
}

TEST_F(OtaHalTest, setDownloadConsent) {
    std::string uuid("uuid");
    StatusCode ret = mOta->setDownloadConsent(uuid, true);
    ASSERT_EQ(StatusCode::SUCCESS, ret);
    StatusCode ret1 = mOta->setDownloadConsent(uuid, false);
    ASSERT_EQ(StatusCode::SUCCESS, ret1);
}

TEST_F(OtaHalTest, setInstallationConsent) {
    std::string uuid("uuid");
    StatusCode ret = mOta->setInstallationConsent(uuid, InstallationConsent::Granted, 0);
    ASSERT_EQ(StatusCode::SUCCESS, ret);
    StatusCode ret1 = mOta->setInstallationConsent(uuid, InstallationConsent::Revoked, 0);
    ASSERT_EQ(StatusCode::SUCCESS, ret1);
    StatusCode ret2 = mOta->setInstallationConsent(uuid, InstallationConsent::Scheduled, 3600);
    ASSERT_EQ(StatusCode::SUCCESS, ret2);
}

TEST_F(OtaHalTest, setOTAHMILanguageSettings) {
    StatusCode ret = mOta->setOTAHMILanguageSettings(Languages::ChineseSimpMan);
    ASSERT_EQ(StatusCode::SUCCESS, ret);
}
